{% macro nav_link(menu_item) %}
    {% if menu_item.id is has_permission %}
        {% if menu_item.child %}
            <li class="tpl-left-nav-item {% if 'link' is has_permission %} test {% endif %}">
                <a href="javascript:void(0);" class="nav-link tpl-left-nav-link-list {% if menu_item.endpoint_prefix in request.endpoint %} active {% endif %}">
                    <i class="am-icon-table"></i>
                    <span>{{ menu_item.name }}</span>
                    <i class="am-icon-angle-right tpl-left-nav-more-ico am-fr am-margin-right{% if menu_item.endpoint_prefix in request.endpoint %} tpl-left-nav-more-ico-rotate {% endif %}"></i>
                </a>
                <ul class="tpl-left-nav-sub-menu" style="display:{% if menu_item.endpoint_prefix in request.endpoint %} block {% else %} none {% endif %};">
                    <li>
                        {% for child in menu_item.child %}
                            {% if child.id is has_permission  %}
                                 <a href="{{ url_for(child.endpoint) }}" class="{% if request.endpoint.endswith(child.endpoint) %}active{% endif %}">
                                    <i class="am-icon-angle-right"></i>
                                    <span>{{ child.name }}</span>
                                    <i class="am-icon-star tpl-left-nav-content-ico am-fr am-margin-right"></i>
                                 </a>
                            {% endif %}
                        {% endfor %}
                    </li>
                </ul>
            </li>
        {% else %}
            <li class="tpl-left-nav-item">
                <a href="{{ url_for(menu_item.endpoint) }}" class="nav-link {% if request.endpoint.endswith(menu_item.endpoint) %}active{% endif %}">
                    <i class="am-icon-home"></i>
                    <span>{{menu_item.name}}</span>
                </a>
            </li>
        {% endif %}
    {% endif %}

{% endmacro %}

{% macro permission_checkbox(memus,role_menus) %}
    <ul class="permission_f_ul">
        {% for menu_item in memus %}
            <li class="checkbox-{{ menu_item.id }}">
                <div class="per_checkbox">
                    <label>
                        <input {% if menu_item.id in role_menus %}checked{% endif %} data-id="{{ menu_item.id }}" class="parent" type="checkbox" value="{{ menu_item.id }}"> {{ menu_item.name }}
                    </label>
                </div>
            {% if menu_item.child %}
                <ul class="permission_s_ul">
                    {% for child in menu_item.child %}
                        <li class="checkbox-{{ child.id }}" father-id="{{ menu_item.id }}">
                            <div class="per_checkbox">
                                <label>
                                    <input {% if child.id in role_menus %}checked{% endif %} data-id="{{ child.id }}" class="child" type="checkbox" value="{{ child.id }}"> {{ child.name }}
                                </label>
                            </div>
                        </li>
                    {% endfor %}
                </ul>
            {% endif %}

            </li>
        {% endfor %}
    </ul>


{% endmacro %}
